package com.gwd.task.model;

import cn.hutool.core.bean.BeanUtil;
import com.gwd.task.entity.ProjectEntity;
import com.gwd.task.group.GroupInsert;
import com.gwd.task.group.GroupUpdate;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zhiyongming
 * @date 2020/11/19 14:36
 */
@Data
public class ProjectDTO {
    @NotNull(message = "项目id不能为空", groups = {GroupUpdate.class})
    @Null(message = "项目id不能传入", groups = {GroupInsert.class})
    private Long projectId;
    @NotBlank(message = "项目名称不能为空", groups = {GroupInsert.class, GroupUpdate.class})
    private String projectName;
    @NotNull(message = "所属组别不能为空", groups = {GroupInsert.class, GroupUpdate.class})
    private Long groupId;
    @NotBlank(message = "编号缩写不能为空", groups = {GroupInsert.class, GroupUpdate.class})
    private String code;
    //当前对大编号统计
    private Integer peNum;
    private Integer devNum;
    private Integer testNum;

    private String groupName;
    private Integer status;
    private String describe;
    private List<ProjectModuleDTO> modules;

    public ProjectDTO() {}
    public ProjectDTO(ProjectEntity entity) {
        BeanUtil.copyProperties(entity, this);
    }
    public void addModule(ProjectModuleDTO module) {
        if (this.modules==null) {
            this.modules = new ArrayList<>();
        }
        this.modules.add(module);
    }
}
